package com.leal.elasticsearch;

import java.util.List;

/**
 * @Classname bigdata
 * @Description es mapping infos
 * @Date 2023/8/15 16:17
 * @Created by leal
 */
public class ESMapping {
    // 字段名称
    private String fieldName;
    // 字段类型
    private String fieldType;
    // 是否分词
    private final Boolean isParticiple;
    // 复合字段
    private List<ESMapping> complexField;

    public ESMapping(String fieldName, String fieldType, Boolean isParticiple) {
        this.fieldName = fieldName;
        this.fieldType = fieldType;
        this.isParticiple = isParticiple;
    }

    public String getFieldName() {
        return fieldName;
    }

    public void setFieldName(String fieldName) {
        this.fieldName = fieldName;
    }

    public String getFieldType() {
        return fieldType;
    }

    public void setFieldType(String fieldType) {
        this.fieldType = fieldType;
    }

    public Boolean getParticiple() {
        return isParticiple;
    }


    public List<ESMapping> getComplexField() {
        return complexField;
    }

    public void setComplexField(List<ESMapping> complexField) {
        this.complexField = complexField;
    }

    @Override
    public String toString() {
        return "ESFieldMappingInfo{" +
                "fieldName='" + fieldName + '\'' +
                ", fieldType='" + fieldType + '\'' +
                ", isParticiple=" + isParticiple +
                ", complexField=" + complexField +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ESMapping that = (ESMapping) o;

        if (isParticiple != that.isParticiple) return false;
        if (fieldName != null ? !fieldName.equals(that.fieldName) : that.fieldName != null) return false;
        if (fieldType != null ? !fieldType.equals(that.fieldType) : that.fieldType != null) return false;
        return complexField != null ? complexField.equals(that.complexField) : that.complexField == null;

    }

    @Override
    public int hashCode() {
        int result = fieldName != null ? fieldName.hashCode() : 0;
        result = 31 * result + (fieldType != null ? fieldType.hashCode() : 0);
        result = 31 * result + (isParticiple ? 1 : 0);
        result = 31 * result + (complexField != null ? complexField.hashCode() : 0);
        return result;
    }
}
